<?php
function Displayconfigse($name,$arrvalue,$arrname=array())
{
global $dbsql,$language;

	$sql_select="select cValue from tblconfig where cName='$name' and cLanguage='$language'";
	if($result=$dbsql->query_fetch($sql_select))
	{
		$select=$result['cValue'];
	}else
	{
		$sql_insert="insert into tblconfig(cName,cValue,cLanguage) values('$name','$arrvalue[0]','$language')";
		$dbsql->query($sql_insert);
	}


	$return="";
	if(!in_array($select,$arrvalue))
	{
		$select=$arrvalue[0];
	}
	foreach ($arrvalue as $i=> $value)
	{
		$return.='<label for="id_'.$name.$value.'">
	 	  			<input type="radio" name="'.$name.'" id="id_'.$name.$value.'" value="'.$value.'"
	 	  			'.(($select==$value)?'checked="checked"':'').'>
	 	  			'.$value.'</label>';
	}
	return $return;
}

function Displayconfig($name,$width=200)
{
global $dbsql,$language;

	$sql_select="select cValue from tblconfig where cName='$name' and cLanguage='$language'";
	if($result=$dbsql->query_fetch($sql_select))
	{
		$value=$result['cValue'];
	}else
	{
		$sql_insert="insert into tblconfig(cName,cValue,cLanguage) values('$name','','$language')";
		$dbsql->query($sql_insert);
	}
	return '<input class="normal3" style="width:'.$width.'px" name="'.$name.'" value="'.$value.'">';
}

function ConfigTimeZoneDefault()
{
global $dbsql,$language;
    $zonelist = array
    (
        'Kwajalein' => -12.00,
        'Pacific/Midway' => -11.00,
        'Pacific/Honolulu' => -10.00,
        'America/Anchorage' => -9.00,
        'America/Los_Angeles' => -8.00,
        'America/Denver' => -7.00,
        'America/Tegucigalpa' => -6.00,
        'America/New_York' => -5.00,
        'America/Caracas' => -4.30,
        'America/Halifax' => -4.00,
        'America/St_Johns' => -3.30,
        'America/Argentina/Buenos_Aires' => -3.00,
        'America/Sao_Paulo' => -3.00,
        'Atlantic/South_Georgia' => -2.00,
        'Atlantic/Azores' => -1.00,
        'Europe/Dublin' => 0,
        'Europe/Belgrade' => 1.00,
        'Europe/Minsk' => 2.00,
        'Asia/Kuwait' => 3.00,
        'Asia/Tehran' => 3.30,
        'Asia/Muscat' => 4.00,
        'Asia/Yekaterinburg' => 5.00,
        'Asia/Kolkata' => 5.30,
        'Asia/Katmandu' => 5.45,
        'Asia/Dhaka' => 6.00,
        'Asia/Rangoon' => 6.30,
        'Asia/Krasnoyarsk' => 7.00,
        'Asia/Brunei' => 8.00,
        'Asia/Seoul' => 9.00,
        'Australia/Darwin' => 9.30,
        'Australia/Canberra' => 10.00,
        'Asia/Magadan' => 11.00,
        'Pacific/Fiji' => 12.00,
        'Pacific/Tongatapu' => 13.00
    );
    $value    =  'Asia/Krasnoyarsk';
    $sql_select="select cValue from tblconfig where cName='TimeZoneDefault' and cLanguage='$language'";
	if($result=$dbsql->query_fetch($sql_select))
	{
		$value=$result['cValue'];
	}else
	{
		$sql_insert="insert into tblconfig(cName,cValue,cLanguage) values('TimeZoneDefault','$value','$language')";
		$dbsql->query($sql_insert);
	}
    $html   = '<select name="TimeZoneDefault">';
    foreach($zonelist as $str=>$vl)
    {
        $vl=($vl>0)? "(+ $vl )" : "( $vl )";
        if($value==$str)
        {
            $html.="<option value='$str' selected>$str $vl</option>";
        }else
        {
            $html.="<option value='$str'>$str $vl</option>";
        }
        
    }
    $html.='</select>';
    return $html;
}


?>